
import { _decorator, Component, Node, Vec3, Tween, dragonBones } from 'cc';
import { RoleBase } from '../../RoleBase';
const { ccclass, property } = _decorator;



@ccclass('Tantalus')
export class Tantalus extends RoleBase {
    public attackName = "Attack Slash";
    public thisV3: Vec3;
    public emm:{v3: Vec3,attackCompletionCallback:(isInAction:boolean) => any};
    onLoad() {
        this.actorName = "Tantalus"
        this.skeleton.addEventListener(dragonBones.EventObject.COMPLETE,this.OnCallAnimationPlayComplete,this);
    }
    public attacks(args:{
        v3: Vec3,
        attackCompletionCallback:(isInAction:boolean) => any
    }){
        this.emm = args;
        this.thisV3 = this.node.getPosition();
        args.v3 = new Vec3(args.v3.x - 150, args.v3.y, args.v3.z);
        new Tween(this.node).to(0.5, { position: args.v3 },{
            'onComplete': () =>{
                this.skeleton.playAnimation(this.attackName,1);
            }
        }).start();
    }
    public freedErupt() {

    }
    OnCallAnimationPlayComplete(event: Event){
        if (event.type === dragonBones.EventObject.COMPLETE) {
            console.log("攻击完毕");
            this.skeleton.playAnimation("Idle",0);
            new Tween(this.node).to(0.5, { position: this.thisV3 },{
                'onComplete': () =>{
                    this.emm.attackCompletionCallback(false);
                }
            }).start();

        }
    }
}

